<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	request.setCharacterEncoding("UTF-8");
	String cp = request.getContextPath(); 
	
	//Json : Map과 같이 [키:값] 데이터를 전송
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="<%=cp%>/data/js/jquery-1.8.2.min.js"></script>

<script type="text/javascript">
	$(function(){
		
		$("#sendButton").click(function(){
			var params = "userName=" +$("#userName").val() + "&userAge=" +$("#userAge").val();
			
			$.ajax({
				
				type:"post",
				url:"a3_ok.jsp",
				data:params,
				dataType:'json',
				success:function(args){
					
					var str ="";
					for(var i=0; i < args.length; i++){
						
						str += "id=" +args[i].id;
						str += ",userName=" +args[i].userName;
						str += ",userAge=" +args[i].userAge+ "<br/>";
					}
					$("#resultDIV").html(str);
				},
				error:function(e){
					alert(e.responseText);
				}
			});
		});
	});
</script>

</head>
<body>
이름 : <input type="text" id="userName"/><br/>
나이 : <input type="text" id="userAge"/><br/>
<input type="button" value="보내기" id="sendButton"/>
<div id="resultDIV"></div>


</body>
</html>